local skel = fk.CreateSkill {
  name = "rmt__tanghuang",
}

skel:addEffect("active", {
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  prompt = "#rmt__tanghuang",
  card_filter = Util.FalseFunc,
  can_use = function(self, player)
    return player:getMark("@@rmt__tanghuang") == 0 and not player:isKongcheng()
    and player:canUse(Fk:cloneCard("slash"))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:setPlayerMark(player, "@@rmt__tanghuang", 1)
    player:filterHandcards()
  end,
})

skel:addEffect(fk.AskForCardUse, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and player:getMark("@@rmt__tanghuang") == 0 and not player:isKongcheng() then
      return Exppattern:Parse(data.pattern):matchExp("slash")
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#rmt__tanghuang"})
  end,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@rmt__tanghuang", 1)
    player:filterHandcards()
  end,
})

skel:addEffect(fk.AskForCardResponse, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) and player:getMark("@@rmt__tanghuang") == 0 and not player:isKongcheng() then
      return Exppattern:Parse(data.pattern):matchExp("slash")
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#rmt__tanghuang"})
  end,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@rmt__tanghuang", 1)
    player:filterHandcards()
  end,
})

skel:addEffect(fk.BuryVictim, {
  is_delay_effect = true,
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return player:getMark("@@rmt__tanghuang") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@rmt__tanghuang", 0)
    player:filterHandcards()
    if not player.room:isGameMode("role_mode") then return end
    -- 按身份局执行奖惩……
    if target.role == "rebel" then
      player:drawCards(3, "kill")
    elseif target.role == "loyalist" then
      player:throwAllCards("he")
    end
  end,
})

skel:addEffect("filter", {
  card_filter = function(self, card, player)
    return player:getMark("@@rmt__tanghuang") ~= 0 and table.contains(player.player_cards[Player.Hand], card.id)
  end,
  view_as = function(self, player, card)
    local c = Fk:cloneCard("fire__slash", card.suit, card.number)
    c.skillName = "rmt__tanghuang"
    return c
  end,
})

Fk:loadTranslationTable{
  ["rmt__tanghuang"] = "煻煌",
  [":rmt__tanghuang"] = "你需要使用或打出【杀】时，可以令你的所有手牌均视为火【杀】至有角色死亡，然后你须执行主公杀死其的奖惩。",
  ["@@rmt__tanghuang"] = "煻煌",
  ["#rmt__tanghuang"] = "煻煌：你可以令所有手牌视为火【杀】！",

  ["$rmt__tanghuang1"] = "Rinasco libero e forte！（我已重生，自由而强大！）",
  ["$rmt__tanghuang2"] = "Cantano i versi miei.（他们在吟唱我的诗篇！）",
  ["$rmt__tanghuang3"] = "No！Fortuna in fronte！（不，好运尚在前方！）",
}

return skel
